home *** CD-ROM | disk | FTP | other *** search
- /*
- A short program designed to convert an integer to it's ASCII values.
- (i.e. 65793 would come to 1 1 1 which means there is one of each of
- the following numbers in that value.)
- 65536
- 256
- 1
-
- Programming: Bryan Carver (CodeLord)
-
- This source is copyright (c) Perspective Video & Electronics,
- http://www.pvid.com
-
- Permission granted to use, abuse, re-write, distribute, and delete
- this code in any means you wish.
- */
- #include <stdio.h>
- #include <iostream.h> //cin
-
- //#include <conio.h>
- //#include <stdlib.h>
- //#include <string.h>
-
- main()
- {
- int cred1, cred2, cred3, cred4;
- unsigned long credits, tempnum;
-
- credits = 0;
-
- // cred4 = 16777215;
- printf("Maximum supportable number of this program is 16,777,215\n");
- printf("Please omit all comma's\n\n");
- printf("Enter the value you wish to convert: ");
- cin >> credits;
-
- cred3 = credits / 65536;
- tempnum = cred3 * 65536;
- credits = credits - tempnum;
- cred2 = credits / 256;
- tempnum = cred2 * 256;
- credits = credits - tempnum;
- cred1 = credits / 1;
- tempnum = cred1 * 1;
- credits = credits - tempnum;
- if (cred3 >= 256){
- printf("\n\nNumber too large to compute\nTry a smaller integer\n");
- cred1 = 0;
- cred2 = 0;
- cred3 = 0;
- }
-
- /*
- char credits;
- cin >> credits;
- printf("%d", credits);
- */
- printf("\n\nConversion...\n");
- printf("Ones : %d\n", cred1);
- printf("256's : %d\n", cred2);
- printf("65536's : %d\n", cred3);
- // printf("4294967296's: %d\n", cred4);
-
- return(0);
- }
-